Next | Prev | Up | Top | Contents | Index

Memory-Mapped I/O

When an input file has a fixed size, the simplest as well as the fastest access method is to map the file into memory (for details on mapping files and other objects into memory, see the book Topics in IRIX Programming). A file that represents a data base of some kind--for example a file of scenery elements, or a file containing a precalculated table of operating parameters for simulated hardware--is best mapped into memory and accessed as a memory array. A mapped file of reasonable size can be locked into memory so that access to it is always fast (see "Locking Mapped Files Into Memory").

You can also perform output on a memory-mapped file simply by storing into the memory image. When the mapped segment is also locked in memory, you control when the actual write takes place. Output happens only when the program calls msync() or changes the mapping of the file. At that time the modified pages are written. (See the msync(2) reference page.) The time-consuming call to msync() can be made from an asynchronous process.



Next | Prev | Up | Top | Contents | Index